home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1990-1992 by Michael Davidson.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for any purpose and without fee is hereby
- * granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission
- * notice appear in supporting documentation.
- *
- * This software is provided "as is" without express or implied warranty.
- */
-
- /*
- * trident.c - support routines for Trident 8800 and 8900
- */
-
- #include "vdev.h"
- #include "svga.h"
-
- /*
- * table of video modes supported for Trident 8800 and 8900
- */
- #define GRAPHICS (SVGA_MODE_SUPPORTED | SVGA_GRAPHICS_MODE)
- #define TEXT (SVGA_MODE_SUPPORTED | SVGA_TEXT_MODE)
-
- static struct svga_mode_info trident_modes[] =
- {
- { 1024, 768, 8, 0x62, GRAPHICS },
- { 800, 600, 8, 0x5e, GRAPHICS },
- { 640, 480, 8, 0x5d, GRAPHICS },
- { 640, 400, 8, 0x5c, GRAPHICS },
- { 320, 200, 8, 0x13, GRAPHICS },
- { 132, 30, 0, 0x54, TEXT },
- { 80, 25, 0, 0x03, TEXT },
- { 0, 0, 0, 0x00, 0 }
- };
-
- static void trident_bank_switch();
- static int trident_present();
-
- /*ARGSUSED*/
- int
- trident_init(
- char *name,
- struct vdev *v
- )
- {
- int r;
-
- if (! (r = trident_present()))
- return -1;
-
- svga_setup(v, trident_modes, trident_bank_switch);
-
- v->v_name = (r == 8900) ? "Trident 8900"
- : "Trident 8800";
- return 0;
- }
-
- int
- trident_probe()
- {
- return trident_present();
- }
-
- static int
- trident_present()
- {
- int old;
- int new;
-
- outb(0x3c4, 0x0e);
- old = inb(0x3c5);
- outb(0x3c5, 0x00);
- new = inb(0x3c5) & 0x0f;
- outb(0x3c5, old);
- if (new != 0x02)
- return 0; /* not trident */
-
- outb(0x3c4, 0x0b);
- outb(0x3c5, 0x00);
- new = inb(0x3c5);
-
- if (new >= 0x03)
- return 8900;
- else
- return 8800;
- }
-
- /*
- * trident_bank_switch()
- */
- static void
- trident_bank_switch(
- int x
- )
- {
- int z;
-
- outb(0x3ce, 0x06);
- z = inb(0x3cf);
- outb(0x3ce, 0x06);
- outb(0x3cf, (z & 0xf3) | 4);
-
- outb(0x3c4, 0x0b);
- inb(0x3c5);
-
- outb(0x3c4, 0x0e);
- outb(0x3c5, x ^ 0x02);
- }
-